using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

public class CameraHeightRenderPass : ScriptableRenderPass
{
    private CameraHeightRendererFeature.Settings m_settings;
    private string m_ProfilerTag;
    private ScriptableRenderer m_renderer;
    
    public CameraHeightRenderPass(string tag, CameraHeightRendererFeature.Settings settings)
    {
        m_ProfilerTag = tag;
        m_settings = settings;
    }

    public void Setup(ScriptableRenderer renderer)
    {
        m_renderer = renderer;
    }

    public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
    {
        var command = CommandBufferPool.Get(m_ProfilerTag);
        var source = m_renderer.cameraDepthTargetHandle;
        
        command.Blit(source, m_settings.m_RenderTexture, m_settings.m_BlitMaterial);
        context.ExecuteCommandBuffer(command);
        CommandBufferPool.Release(command);
    }
}
